﻿namespace mVids
{
    using System;
    using System.ComponentModel;
    using System.Drawing;
    using System.Windows.Forms;

    public class artistUC : UserControl
    {
        private string artist;
        public TextBox artistBox;
        public TextBox bioBox;
        public TextBox bioFullBox;
        private Button button1;
        private IContainer components = null;
        private mVids.database db;
        private Label label1;
        private Label label2;
        private Label label3;
        private Label label7;
        private string lfmname;
        public TextBox lfmNamebox;
        private Button saveButton;
        private TabControl tabControl1;
        private TabPage tabPage1;
        private TabPage tabPage2;
        private TextBox tagBox;

        public artistUC(object datab, string artistName, string lfmName, string tags, string shortBio, string fullBio)
        {
            this.InitializeComponent();
            this.db = (mVids.database) datab;
            this.artistBox.Text = artistName;
            this.artist = artistName;
            this.lfmname = lfmName;
            this.lfmNamebox.Text = lfmName;
            this.tagBox.Text = tags;
            this.bioBox.Text = shortBio;
            this.bioFullBox.Text = fullBio;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            mVids.artistInfo info = new mVids.lastFM().getArtistInfo(this.db.getArtistInfo(this.artist));
            this.artistBox.Text = info.name;
            this.lfmNamebox.Text = info.lfmName;
            this.tagBox.Text = info.tags;
            this.bioBox.Text = info.bioSummary;
            this.bioFullBox.Text = info.bioContent;
            MessageBox.Show("Information synched with last.fm. Don't forget to click the Save button.", "Success", MessageBoxButtons.OK, MessageBoxIcon.Asterisk, MessageBoxDefaultButton.Button1);
        }

        protected override void Dispose(bool disposing)
        {
            if (disposing && (this.components != null))
            {
                this.components.Dispose();
            }
            base.Dispose(disposing);
        }

        private void InitializeComponent()
        {
            this.artistBox = new TextBox();
            this.label1 = new Label();
            this.label7 = new Label();
            this.tabControl1 = new TabControl();
            this.tabPage1 = new TabPage();
            this.bioBox = new TextBox();
            this.tabPage2 = new TabPage();
            this.bioFullBox = new TextBox();
            this.lfmNamebox = new TextBox();
            this.label2 = new Label();
            this.label3 = new Label();
            this.tagBox = new TextBox();
            this.saveButton = new Button();
            this.button1 = new Button();
            this.tabControl1.SuspendLayout();
            this.tabPage1.SuspendLayout();
            this.tabPage2.SuspendLayout();
            base.SuspendLayout();
            this.artistBox.Anchor = AnchorStyles.Right | AnchorStyles.Left;
            this.artistBox.Location = new Point(0x4f, 15);
            this.artistBox.Name = "artistBox";
            this.artistBox.Size = new Size(0xc3, 20);
            this.artistBox.TabIndex = 0x26;
            this.label1.Anchor = AnchorStyles.Right | AnchorStyles.Left;
            this.label1.AutoSize = true;
            this.label1.Enabled = false;
            this.label1.Location = new Point(0x29, 0x12);
            this.label1.Name = "label1";
            this.label1.Size = new Size(0x21, 13);
            this.label1.TabIndex = 0x20;
            this.label1.Text = "Artist:";
            this.label7.Anchor = AnchorStyles.Right | AnchorStyles.Left;
            this.label7.AutoSize = true;
            this.label7.Location = new Point(8, 0x69);
            this.label7.Name = "label7";
            this.label7.Size = new Size(0x19, 13);
            this.label7.TabIndex = 0x23;
            this.label7.Text = "Bio:";
            this.tabControl1.Controls.Add(this.tabPage1);
            this.tabControl1.Controls.Add(this.tabPage2);
            this.tabControl1.Location = new Point(0x27, 0x51);
            this.tabControl1.Multiline = true;
            this.tabControl1.Name = "tabControl1";
            this.tabControl1.SelectedIndex = 0;
            this.tabControl1.Size = new Size(0x284, 0xfd);
            this.tabControl1.TabIndex = 0x2a;
            this.tabPage1.Controls.Add(this.bioBox);
            this.tabPage1.Location = new Point(4, 0x16);
            this.tabPage1.Name = "tabPage1";
            this.tabPage1.Padding = new Padding(3);
            this.tabPage1.Size = new Size(0x270, 0xe7);
            this.tabPage1.TabIndex = 0;
            this.tabPage1.Text = "Summary";
            this.tabPage1.UseVisualStyleBackColor = true;
            this.bioBox.Dock = DockStyle.Fill;
            this.bioBox.Location = new Point(3, 3);
            this.bioBox.Multiline = true;
            this.bioBox.Name = "bioBox";
            this.bioBox.ScrollBars = ScrollBars.Both;
            this.bioBox.Size = new Size(0x26a, 0xe1);
            this.bioBox.TabIndex = 9;
            this.tabPage2.Controls.Add(this.bioFullBox);
            this.tabPage2.Location = new Point(4, 0x16);
            this.tabPage2.Name = "tabPage2";
            this.tabPage2.Padding = new Padding(3);
            this.tabPage2.Size = new Size(0x27c, 0xe3);
            this.tabPage2.TabIndex = 1;
            this.tabPage2.Text = "Full";
            this.tabPage2.UseVisualStyleBackColor = true;
            this.bioFullBox.Dock = DockStyle.Fill;
            this.bioFullBox.Location = new Point(3, 3);
            this.bioFullBox.Multiline = true;
            this.bioFullBox.Name = "bioFullBox";
            this.bioFullBox.ScrollBars = ScrollBars.Both;
            this.bioFullBox.Size = new Size(630, 0xdd);
            this.bioFullBox.TabIndex = 10;
            this.lfmNamebox.Anchor = AnchorStyles.Right | AnchorStyles.Left;
            this.lfmNamebox.Location = new Point(0x176, 15);
            this.lfmNamebox.Name = "lfmNamebox";
            this.lfmNamebox.Size = new Size(0xa2, 20);
            this.lfmNamebox.TabIndex = 0x2c;
            this.label2.Anchor = AnchorStyles.Right | AnchorStyles.Left;
            this.label2.AutoSize = true;
            this.label2.Location = new Point(0x12d, 0x12);
            this.label2.Name = "label2";
            this.label2.Size = new Size(0x45, 13);
            this.label2.TabIndex = 0x2b;
            this.label2.Text = "last.fm name:";
            this.label3.AutoSize = true;
            this.label3.Location = new Point(40, 0x2d);
            this.label3.Name = "label3";
            this.label3.Size = new Size(0x22, 13);
            this.label3.TabIndex = 0x2d;
            this.label3.Text = "Tags:";
            this.tagBox.Location = new Point(0x4f, 0x2a);
            this.tagBox.Name = "tagBox";
            this.tagBox.Size = new Size(0x1c9, 20);
            this.tagBox.TabIndex = 0x2e;
            this.saveButton.Anchor = AnchorStyles.Right | AnchorStyles.Left;
            this.saveButton.BackColor = SystemColors.ButtonFace;
            this.saveButton.FlatAppearance.BorderColor = Color.Red;
            this.saveButton.Location = new Point(0x251, 15);
            this.saveButton.Name = "saveButton";
            this.saveButton.Size = new Size(90, 0x2b);
            this.saveButton.TabIndex = 0x2f;
            this.saveButton.Text = "Save Record";
            this.saveButton.UseVisualStyleBackColor = true;
            this.saveButton.Click += new EventHandler(this.saveButton_Click);
            this.button1.Location = new Point(0x251, 0x3d);
            this.button1.Name = "button1";
            this.button1.Size = new Size(90, 0x24);
            this.button1.TabIndex = 0x30;
            this.button1.Text = "Update from last.fm";
            this.button1.UseVisualStyleBackColor = true;
            this.button1.Click += new EventHandler(this.button1_Click);
            base.AutoScaleDimensions = new SizeF(6f, 13f);
            base.AutoScaleMode = AutoScaleMode.Font;
            base.Controls.Add(this.button1);
            base.Controls.Add(this.saveButton);
            base.Controls.Add(this.tagBox);
            base.Controls.Add(this.label3);
            base.Controls.Add(this.lfmNamebox);
            base.Controls.Add(this.label2);
            base.Controls.Add(this.tabControl1);
            base.Controls.Add(this.artistBox);
            base.Controls.Add(this.label1);
            base.Controls.Add(this.label7);
            base.Name = "artistUC";
            base.Size = new Size(700, 350);
            this.tabControl1.ResumeLayout(false);
            this.tabPage1.ResumeLayout(false);
            this.tabPage1.PerformLayout();
            this.tabPage2.ResumeLayout(false);
            this.tabPage2.PerformLayout();
            base.ResumeLayout(false);
            base.PerformLayout();
        }

        private void saveButton_Click(object sender, EventArgs e)
        {
            if (this.db.updateArtist(this.artistBox.Text, this.artist, this.lfmNamebox.Text, this.lfmname, this.bioBox.Text.Replace("\"", "'"), this.bioFullBox.Text.Replace("\"", "'"), this.tagBox.Text, null))
            {
                MessageBox.Show(this.artistBox.Text + " updated", "", MessageBoxButtons.OK, MessageBoxIcon.Asterisk, MessageBoxDefaultButton.Button1);
            }
            base.Dispose();
        }
    }
}

